#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;
//void Reverse(string& s)
//{
//    int begin = 0;
//    int end = s.size() - 1;
//    while (begin < end)
//    {
//        char ch = s[begin];
//        s[begin] = s[end];
//        s[end] = ch;
//        begin++;
//        end--;
//    }
//}
//int main()
//{
//    string s;
//    getline(cin, s);
//    Reverse(s);
//    cout << s << endl;
//}
void count_equal(string& s1, string& s2, int& ret, int& count, int begin1, int begin2)
{
    if (begin1 >= s1.size() || begin2 >= s2.size())
    {
        if (count > ret)
        {
            ret = count;
        }
        count = 0;
        return;
    }
    if (s1[begin1] != s2[begin2])
    {
        if (count > ret)
        {
            ret = count;
        }
        count = 0;
        return;
    }
    else
    {
        count++;
        count_equal(s1, s2, ret, count, begin1 + 1, begin2 + 1);
    }
}

int main()
{
    string s1;
    string s2;
    getline(cin, s1);
    getline(cin, s2);
    int count = 0;
    int ret = 0;
    for (int i = 0; i < s1.size(); i++)
    {
        for (int j = 0; j < s2.size(); j++)
        {
            count_equal(s1, s2, ret, count, i, j);
        }
    }
    cout << ret << endl;
    return 0;
}